package com.example.xuwsh.myBatisPlus.utils;

import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.example.xuwsh.myBatisPlus.fun.ColumnService;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @Author: xuwsh
 * @Date: 2023/09/21/18:18
 * @Description:
 */
public class JuXiMapUtils<T> implements JuXiMap<SFunction<T, ?>, String> {
    Map<String, Object> map;
    ColumnService<T> columnService;

    public JuXiMapUtils() {
        map = new HashMap<>();
        columnService = new ColumnService<>();
    }

    @Override
    public Map<String, Object> getMap() {
        return map;
    }

    @Override
    public void put(SFunction<T, ?> key, Object val) {
        String filed = columnService.getFiled(key);
        map.put(filed, val);
    }

    @Override
    public void remove(SFunction<T, ?> key) {
        String filed = columnService.getFiled(key);
        map.remove(filed);
    }

    @Override
    public void clear() {
        map.clear();
    }

    @Override
    public Object getValue(SFunction<T, ?> key) {
        String filed = columnService.getFiled(key);
        return map.get(filed);
    }

    @Override
    public Set<Map.Entry<String, Object>> entrySet() {
        return map.entrySet();
    }

}
